package com.wu.foodsafetyplayer.app.bean;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.List;

public class DeviceByMomeBean implements Parcelable {

    /**
     * hostport : 81
     * hostip : daxun.tpddns.cn
     * serviceport : 53403
     * serviceip : daxun.tpddns.cn
     * items : [{"valid":1,"ip":"10.9.0.102","id":3240,"channels":[{"deviceid":3240,"valid":1,"channel":0,"name":"CH 1"}],"port":554,"path":"test/demo","name":"augesion_test"}]
     * result : 0
     * user : admin
     */

    public int hostport;
    public String hostip;
    public int serviceport;
    public String serviceip;
    public int result;
    public String user;
    public List<ItemsBean> items;


    public static class ItemsBean implements Parcelable {
        /**
         * valid : 1
         * ip : 10.9.0.102
         * id : 3240
         * channels : [{"deviceid":3240,"valid":1,"channel":0,"name":"CH 1"}]
         * port : 554
         * path : test/demo
         * name : augesion_test
         */

        public int valid;
        public String ip;
        public int id;
        public int port;
        public String path;
        public String name;
        public List<ChannelsBean> channels;


        public static class ChannelsBean implements Parcelable {
            /**
             * deviceid : 3240
             * valid : 1
             * channel : 0
             * name : CH 1
             */

            public int deviceid;
            public int valid;
            public int channel;
            public String name;
            public String url;
            public String rtspurl;


            public ChannelsBean() {
            }

            @Override
            public int describeContents() {
                return 0;
            }

            @Override
            public void writeToParcel(Parcel dest, int flags) {
                dest.writeInt(this.deviceid);
                dest.writeInt(this.valid);
                dest.writeInt(this.channel);
                dest.writeString(this.name);
                dest.writeString(this.url);
                dest.writeString(this.rtspurl);
            }

            protected ChannelsBean(Parcel in) {
                this.deviceid = in.readInt();
                this.valid = in.readInt();
                this.channel = in.readInt();
                this.name = in.readString();
                this.url = in.readString();
                this.rtspurl = in.readString();
            }

            public static final Creator<ChannelsBean> CREATOR = new Creator<ChannelsBean>() {
                @Override
                public ChannelsBean createFromParcel(Parcel source) {
                    return new ChannelsBean(source);
                }

                @Override
                public ChannelsBean[] newArray(int size) {
                    return new ChannelsBean[size];
                }
            };
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(this.valid);
            dest.writeString(this.ip);
            dest.writeInt(this.id);
            dest.writeInt(this.port);
            dest.writeString(this.path);
            dest.writeString(this.name);
            dest.writeTypedList(this.channels);
        }

        public ItemsBean() {
        }

        protected ItemsBean(Parcel in) {
            this.valid = in.readInt();
            this.ip = in.readString();
            this.id = in.readInt();
            this.port = in.readInt();
            this.path = in.readString();
            this.name = in.readString();
            this.channels = in.createTypedArrayList(ChannelsBean.CREATOR);
        }

        public static final Parcelable.Creator<ItemsBean> CREATOR = new Parcelable.Creator<ItemsBean>() {
            @Override
            public ItemsBean createFromParcel(Parcel source) {
                return new ItemsBean(source);
            }

            @Override
            public ItemsBean[] newArray(int size) {
                return new ItemsBean[size];
            }
        };
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.hostport);
        dest.writeString(this.hostip);
        dest.writeInt(this.serviceport);
        dest.writeString(this.serviceip);
        dest.writeInt(this.result);
        dest.writeString(this.user);
        dest.writeTypedList(this.items);
    }

    public DeviceByMomeBean() {
    }

    protected DeviceByMomeBean(Parcel in) {
        this.hostport = in.readInt();
        this.hostip = in.readString();
        this.serviceport = in.readInt();
        this.serviceip = in.readString();
        this.result = in.readInt();
        this.user = in.readString();
        this.items = in.createTypedArrayList(ItemsBean.CREATOR);
    }

    public static final Parcelable.Creator<DeviceByMomeBean> CREATOR = new Parcelable.Creator<DeviceByMomeBean>() {
        @Override
        public DeviceByMomeBean createFromParcel(Parcel source) {
            return new DeviceByMomeBean(source);
        }

        @Override
        public DeviceByMomeBean[] newArray(int size) {
            return new DeviceByMomeBean[size];
        }
    };
}
